<script>
import {
    useUserStore
} from '@/store/index.js'
export default {
    onLaunch: function () {
        this.checkLogin();
    },
    onShow: function () {
        // this.checkLogin();
    },
    onHide: function () { },
    methods: {
        checkLogin() {
            const userStore = useUserStore()
            const pages = getCurrentPages();
            let currentPage = '';
            if (pages.length > 0) {
                currentPage = pages[pages.length - 1].route;
            }
            if (userStore.token) {
                if (currentPage !== 'pages/mine/index') {
                    uni.switchTab({
                        url: '/pages/mine/index'
                    });
                }
            } else {
                if (currentPage !== 'pages/login/index') {
                    uni.redirectTo({
                        url: '/pages/login/index'
                    });
                }
            }
        }
    }
}
</script>

<style>
/*每个页面公共css */
uni-toast {
z-index: 19999 !important;
}
</style>